<template>
  <svg aria-hidden="true" :style="classValue" class="my-svg">
    <use :xlink:href="symbolId" :fill="color" />
  </svg>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';

export default defineComponent({
  name: 'SvgIcon',
  props: {
    prefix: {
      type: String,
      default: 'icon',
    },
    name: {
      type: String,
      required: true,
    },
    color: {
      type: String,
      default: '#333',
    },
    classValue: {
      default: {
        'width': '22px',
        'height': '22px'
      }
    }
  },
  setup(props) {
    const symbolId = computed(() => `#${props.prefix}-${props.name}`)
    return { symbolId }
  },
})
</script>
<style lang="less" scoped>
.my-svg {
  display: inline;
  margin: 4px;
}
</style>